package com.property.controller;

import com.alibaba.fastjson.JSON;

import com.property.pojo.Resident;
import com.property.service.ResidentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("resident")
public class ResidentController {

    @Autowired
    private ResidentService residentService;
    //显示所有的住户信息
    @RequestMapping("findAllResident")
    public String findAllResident(Integer page){
        return residentService.findAllResident(page);
    }
    //新增住户
    @RequestMapping("saveResident")
    public String saveResident(Resident resident){
        return residentService.saveResident(resident);
    }
    //删除住户
    @RequestMapping("deleteResident")
    public String deleteResident(Integer rId){
        int num = residentService.deleteResident(rId);
        return JSON.toJSONString((num > 0) ? "操作成功":"操作失败");
    }
    //通过id查询住户
    @RequestMapping("findResidentByrId")
    public String findResidentByrId(Integer rId){
        return JSON.toJSONString(residentService.findResidentByrId(rId));
    }


}
